package com.atguigu.orderservice.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 当项目已启动，spring接口，spring加载之后，执行接口一个方法
 */
@Component
public class WePayPropertiesUtils implements InitializingBean {

    //读取微信支付配置文件内容
    @Value("${wx.pay.app_id}")
    private String appId;

    @Value("${wx.pay.mch_id}")
    private String mchId;

    @Value("${wx.pay.partner_key}")
    private String partnerKey;

    @Value("${wx.pay.notify_url}")
    private String notifyUrl;


    //定义公开静态常量
    public static String APP_ID;
    public static String MCH_ID;
    public static String PARTNER_KEY;
    public static String NOTIFY_URL;


    @Override
    public void afterPropertiesSet() throws Exception {
        APP_ID = appId;
        MCH_ID = mchId;
        PARTNER_KEY = partnerKey;
        NOTIFY_URL = notifyUrl;
    }
}
